package br.com.aquinoevasconcelos.servlets.mensagem;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.aquinoevasconcelos.fachada.Fachada;

/**
 * Servlet implementation class ListaClientesMensagem
 */
@WebServlet("/ListaClientesMensagem")
public class ListaClientesMensagem extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public ListaClientesMensagem() {
        super();

    }
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	
    	Fachada fachada = Fachada.getInstancia();
    	
    	try {
			
    		request.setAttribute("logins", fachada.listaCliente());
    		
    		RequestDispatcher rd = request
					.getRequestDispatcher("admin/enviar_mensagens.jsp");
			rd.forward(request, response);
    		
		} catch (Exception e) {
			e.printStackTrace();
			response.sendRedirect("pagina_erro/erro.jsp");
		}
    	
    }


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		service(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		service(request, response);
	}

}
